/**
 * Created by maxiaoqiang on 2018/6/25.
 */

import React, {Component} from "react";
import {HashRouter as Router, Route, Switch} from 'react-router-dom';
import {Layout} from 'antd';
import {connect} from "react-redux";

import "./index.less";

const {Sider, Content} = Layout;

import LayoutHeader from "layouts/header";
import LayoutSider from "layouts/sider";

import UserInfo from "page/userInfo";
import Setting from "page/userInfo/Setting";
import Authority from "page/authority";
import UserManage from "page/usermanage";
// import Course from "page/course";

import Category from "page/course/category";
import Subject from "page/course/subject";
import Chapter from "page/course/chapter";


import Mistakes from "page/mistakes/Mistakes";



import QuestionBank from "page/questionbank";
import Grade from "page/grade";
import Simulate from "page/examcenter/Simulate";
import Official from "page/examcenter/Official";
import PastPaper from "page/examcenter/PastPaper";
import BetPaper from "page/examcenter/BetPaper";



class Layouts extends Component {

    constructor(props) {
        super(props);
        this.state = {
            collapsed: false
        }
    };

    componentDidMount(){
        // console.log(this.props)
    }

    toggle = ()=> {
        this.setState({
            collapsed: !this.state.collapsed
        })
    };

    render() {
        return (
            <Layout className="bkaka-layout">
                <Sider
                    trigger={null}
                    collapsible
                    collapsed={this.state.collapsed}
                >
                    <LayoutSider/>
                </Sider>
                <Layout>
                    <LayoutHeader collapsed={this.state.collapsed} toggle={this.toggle}/>
                    <Content style={{ margin: '24px 16px', padding: 24, background: '#fff', minHeight: 280 }}>
                        <Router>
                            <Switch>
                                <Route path="/exam/userinfo" component={UserInfo} />
                                <Route path="/exam/setting" component={Setting} />
                                <Route path="/exam/authority" component={Authority} />
                                <Route path="/exam/usermanage" component={UserManage} />
                                <Route path="/exam/course/category" component={Category} />
                                <Route path="/exam/course/subject" component={Subject} />
                                <Route path="/exam/course/chapter" component={Chapter} />
                                <Route path="/exam/questionbank" component={QuestionBank} />
                                <Route path="/exam/grade" component={Grade} />
                                <Route path="/exam/simulate" component={Simulate} />
                                <Route path="/exam/official" component={Official} />
                                <Route path="/exam/pastpaper" component={PastPaper} />
                                <Route path="/exam/betpaper" component={BetPaper} />
                                <Route path="/exam/mistake" component={Mistakes} />
                            </Switch>
                        </Router>
                    </Content>
                </Layout>
            </Layout>
        )
    }
}
const mapStateToProps = (state) => ({
    screen: state.screenReducer.screen
});
export default connect(mapStateToProps)(Layouts);
